#pragma once
#ifndef CXML_H
#define CXML_H

#include "bezierPath.h"
#include "frenet.h"
#include "TimeController.h"
#include "LinearFunction.h"
#include "ConstantFloat.h"
#include "PutInVector3.h"
#include "KineticMotion.h"
#include "keyframeAnimation.h"
#include "BezierCoordinate.h"
#include "Rail.h"
#include "Rail2.h"
#include "SinAndCos.h"
#include "Terrain.h"
#include "Canon.h"
#include "AwesomeAttraction.h"
#include "Pillar.h"
#include "Carousel.h"
#include "Oscillator.h"

//particle system includes
#include "LinearFunction.h"
#include "ParticleSystem.h"
#include "ParticlesPoint.h"
#include "PointEmitter.h"
#include "CircleEmitter.h"
#include "FullSquareEmitter.h"
#include "DirectionalPointEmitter.h"
#include "SimpleSimulation.h"
#include "AttractionSimulation.h"
#include "TimeReaper.h"

//xml includes
#include "XmlDebug.h"
#include "TXF.h"

#include <stack>
#include <tsg.h>
using namespace tsg;
using namespace controller;
using namespace gl;

using namespace TXF;
using namespace TXFSTL;
class CXml
{
public:
	enum EElementType
	{
		eTypeCamera,
		eTypeLookAt,
		eTypeBezier3Curve,
		eTypeBezierPath,
		eTypeApplicationTime,
		eTypeParticleSystem,
		eTypeSeparator,
		eTypeMaterial,
		eTypeCube,
		eTypeTranslate,
		eTypeRotate,
		eTypeTimeController,
		eTypeLinearFunction,
		eTypeConstantFloat,
		eTypePutInVector3,
		eTypeKinetic,
		eTypeKeyframe,
		eTypeBezierCoordinates,
		eTypeCosinus,
		eTypeSinus,
		eTypeTerrain,
		eTypeCanon,
		eTypeAwesomeAttraction,
		eTypePillar,
		eTypeGreatWheel,
		eTypeCarousel,
		eTypeUnknown
	};
private:
	struct connectController
	{
		string m_nameOfController;
		void* m_pointerToController;
	};

	Document m_xmlFile;
	Element* m_root;
	ApplicationTime* m_time;
	Group* m_nodeRoot;
	vector<connectController> m_vectorController;

public: //should be private in the future
	int m_windowWidth;
	int m_windowHeight;

public:
	CXml(void);
	~CXml(void);
	bool open(string filename);

	bool read(Group* root, Element* element);
	 
	bool addCamera(Element* node, Group* root);
	bool addLookAt(Element* node, Group* root);
	bool addBezier3Curve(Element* node, Group* root);
	bool addBezierPath(Element* node, Group* root);
	bool addApplicationTime(Element* node, Group* root);
	bool addParticleSystem(Element* node, Group* root);
	bool addSeparator(Element* node, Group* root);
	bool addMaterial(Element* node, Group* root);
	bool addCube(Element* node, Group* root);
	bool addTranslate(Element* node, Group* root);
	bool addRotate(Element* node, Group* root);
	bool addTimeController(Element* node);
	bool addLinearFunction(Element* node);
	bool addConstantFloat(Element* node);
	bool addPutInVector3(Element* node);
	bool addKinetic(Element* node, Group* root);
	bool addKeyframe(Element* node);
	bool addBezierCoordinates(Element* node, Group* root);
	bool addCosinus(Element* node);
	bool addSinus(Element* node);
	bool addTerrain(Element* node, Group* root);
	bool addCanon(Element* node, Group* root);
	bool addAwesomeAttraction(Element* node, Group* root);
	bool addPillar(Element* node, Group* root);
	bool addGreatWheel(Element* node, Group* root);
	bool addCarousel(Element* node, Group* root);

	static int convertNameToInt(Element* node);

	void* getController(string connectFrom);
	void registerController(Element* node, void* controller);

	
	
};

#endif